from django.db import models


# Create your models here.
from malonghui.utils.models import BaseModel


class Spits(BaseModel):
    """
    吐槽详情表
    """
    pesudonym = models.CharField(max_length=10, verbose_name="匿名名称")
    content = models.CharField(max_length=140, verbose_name="吐槽内容")
    like_count = models.IntegerField(verbose_name="点赞数量", default=0)
    share_count = models.IntegerField(verbose_name='分享数量', default=0)

    class Meta:
        db_table = 'tb_spits'  #
        verbose_name = '吐槽详情'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id


class Collect(BaseModel):
    """
    吐槽收藏表
    """
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='用户')
    spits_id = models.ForeignKey(Spits, on_delete=models.CASCADE, verbose_name="收藏吐槽")

    class Meta:
        db_table = 'tb_collect'
        verbose_name = '吐槽收藏'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id


class SpitsImage(BaseModel):
    """
    Spits图片
    """
    spits = models.ForeignKey(Spits, on_delete=models.CASCADE, verbose_name='sku')
    image = models.ImageField(verbose_name='图片')  # ImageField拿到的是文件的名字

    class Meta:
        db_table = 'tb_spits_image'
        verbose_name = 'spits图片'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s' % self.id


class Share(BaseModel):
    """
    吐槽分享表
    """
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='用户')
    spits_id = models.ForeignKey(Spits, on_delete=models.CASCADE, verbose_name="吐槽分享")

    class Meta:
        db_table = 'tb_Share'
        verbose_name = '吐槽分享'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id


class SpitsLike(BaseModel):
    """
    吐槽点赞表
    """
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='用户')
    spits_id = models.ForeignKey(Spits, on_delete=models.CASCADE, verbose_name="吐槽点赞")

    class Meta:
        db_table = 'tb_spits_like'
        verbose_name = '吐槽点赞'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id


class SpitsCommen(BaseModel):
    """
    吐槽评论表
    """
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='用户')
    spits_id = models.ForeignKey(Spits, on_delete=models.CASCADE, verbose_name='吐槽详情')
    countent = models.CharField(max_length=128, verbose_name='评论内容')
    like_count = models.IntegerField(default=0, verbose_name='评论点赞数量')

    class Meta:
        db_table = 'tb_spits_commen'
        verbose_name = '吐槽评论'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id


class SpitsCommentLike(BaseModel):
    """
    吐槽评论点赞表
    """
    user_id = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name='用户')
    comment_id = models.ForeignKey(SpitsCommen, on_delete=models.CASCADE, verbose_name='评论')

    class Meta:
        db_table = 'tb_spits_commen_like'
        verbose_name = '吐槽评论点赞'  # 中文名
        verbose_name_plural = verbose_name  # 是否是复数

    def __str__(self):
        return '%s' % self.id
